package com.aooci.ordercat.domain;

import java.util.Calendar;

import javax.persistence.Column;
import javax.persistence.MappedSuperclass;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Version;

/**
 * base class adding a version timestamp
 * 
 */
@MappedSuperclass
public abstract class VersionableEntity extends IdentityEntity {

	private static final long serialVersionUID = 1L;

	@Column(name = "CREATION_TIMESTAMP", nullable = false, updatable = false)
	@Temporal(TemporalType.TIMESTAMP)
	private Calendar creationTimestamp = Calendar.getInstance();

	@Version
	@Column(name = "MODIFICATION_TIMESTAMP", nullable = false, updatable = true)
	@Temporal(TemporalType.TIMESTAMP)
	private Calendar modificationTimestamp = Calendar.getInstance();

	/**
	 * @return the creationTimestamp
	 */
	public Calendar getCreationTimestamp() {
		return creationTimestamp;
	}

	/**
	 * @param creationTimestamp the creationTimestamp to set
	 */
	public void setCreationTimestamp(Calendar creationTimestamp) {
		this.creationTimestamp = creationTimestamp;
	}

	/**
	 * @return the modificationTimestamp
	 */
	public Calendar getModificationTimestamp() {
		return modificationTimestamp;
	}

	/**
	 * @param modificationTimestamp the modificationTimestamp to set
	 */
	public void setModificationTimestamp(Calendar modificationTimestamp) {
		this.modificationTimestamp = modificationTimestamp;
	}
	
}
